<template>
  <div class="feedback-container">
    <el-row>
      <el-col :span="24">
        <div class="btn-group">
          <!--<el-button @click="handleDownload" type="primary">导出</el-button>-->
          <a :href="exportLink" class="download-btn el-button el-button--primary" title="反馈列表" target="_self" download="反馈列表">导出</a>
        </div>
      </el-col>
    </el-row>
    <el-row class="mgtop20">
      <el-col :span="24">
        <el-table
          border
          :data="tableData.items">
          <el-table-column
            prop="content"
            label="反馈内容"
            align="center"></el-table-column>
          <el-table-column
            prop="createAt"
            label="反馈时间"
            align="center"
            width="200px">
            <template slot-scope="item">
              <span>{{ item.row.createAt | format }}</span>
            </template>
          </el-table-column>
        </el-table>
      </el-col>
    </el-row>
    <el-row>
      <el-col :span="24">
        <app-pagination
          :currentPage.sync="tableData.page"
          :size.sync="tableData.size"
          :total="tableData.total"
          @handleCurrentChange="initData"
          @handleSizeChange="initData"></app-pagination>
      </el-col>
    </el-row>
  </div>
</template>
<script>
  import ApiClient from '@/utils/ApiClient';
  import AppPagination from '@/components/AppPagination';

    export default {
        components: {
          "app-pagination": AppPagination,
        },
        props: {},
        data() {
            return {
              tableData: { // 页面数据
                page: 1,
                size:  10,
                items: null,
                total: null,
                totalPage: null,
              },
              exportLink: null
            }
        },
        methods: {
          initData() {
            ApiClient.get("/backend/feedback/list.do",{
              page: this.tableData.page,
              size: this.tableData.size
            }).then( data => {
              this.tableData = data;
            });
          },
        },
        created() {
          this.initData();
          ApiClient.get("/backend/feedback/export.do").then((data) =>{
            this.exportLink = `${process.env.API_URL_BASE}/commons/attachments/download.do/?filename=${data.filename}&saveName=${data.saveName}`;
          });
        }
    }
</script>
<style lang="scss" scoped>
  .feedback-container{
    .mgtop20{
      margin-top: 20px;
    }
    .btn-group{
      position: relative;
      text-align: right;

    }
  }
</style>
